import {UserList,userforbidden,Adduser,Updateuserinformation} from '@/api/http.js'
import { Message } from 'element-ui';
const state ={
  //用户列表
  userlist:[]
};
const mutations ={
  //用户列表
  USERLIST(state,userlist){
    state.userlist = userlist
  }
};
const actions ={
  //用户列表
  async getUserList({commit},{current,name,email,phone,pageSize}){
   let request = await UserList({current,name,email,phone,pageSize})
   if(request.status==200){
    commit('USERLIST',request.data)
   }
  },
  //用户禁用与启用
 async getuserforbidden({commit},{user}){
  let request = await userforbidden(user)
  if(request.status==204){
    Message({
      message: '操作成功',
      type: 'success'
    });
  }
  },
  //添加用户
 async getAdduser({commit},{name,email,password}){
  let request = await Adduser({name,email,password})
  if(request.status==201){
    Message({
      message: '添加用户成功',
      type: 'success'
    });
  }
  },
  //
  async getUpdateuserinformation({commit},{users,name,email}){
  let request = await Updateuserinformation({users,name,email})
  if(request.status==204){
    Message({
      message: '修改成功',
      type: 'success'
    });
  }
  }
};
const getters ={

}
export default {
  state,
  actions,
  mutations,
  getters
}